# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=pirana
pkgver=0.3.1
pkgrel=9
pkgdesc='Exploitation framework that tests the security of a email content filter.'
url='http://www.guay-leroux.com/projects.html'
groups=('blackarch' 'blackarch-exploitation')
license=('GPL')
arch=('x86_64' 'aarch64')
depends=('perl' 'perl-mime-lite')
source=("https://dl.packetstormsecurity.net/UNIX/audit/$pkgname-$pkgver.tar.gz")
sha512sums=('beb7b1e5a67231c5506b68560eea692131cc6fb8704b7421b375fb957b81a663b370408847f5f8eb63b4b604d97bba7845918c2e96c16dcac1ab2a7880d546c4')

prepare() {
  cd "$pkgname-$pkgver"

  sed -ie '/arpa\/inet.h/a#include <limits.h>/' \
    "exploits/exploit_ARJ_long_filename.c"
}

build() {
  cd "$pkgname-$pkgver"

  make CC="gcc $CFLAGS"
}

package() {
  cd "$pkgname-$pkgver"

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec perl $pkgname.pl "\$@"
EOF

  chmod 0755 "$pkgdir/usr/bin/$pkgname" "$pkgdir/usr/share/$pkgname/$pkgname.pl"
}

